package framework.log;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.InputStream;

/**
 * 日志框架
 *
 * @author ME
 * @date   2019/11/12
 */
public class TestLog {

    static{
        // SLF4JBridgeHandler.install();

        // 设置 jul 配置文件
        System.setProperty("java.util.logging.config.file", "testJDK8/src/main/resources/jul.properties");
    }

    private static final Logger slf4j = LoggerFactory.getLogger(TestLog.class);

    /**
     * jcl-over-slf4j:  commons-logging  -->  slf4j
     *      slf4j-jcl:            slf4j  -->  commons-logging
     */
    private static final org.apache.commons.logging.Log jcl = org.apache.commons.logging.LogFactory.getLog(TestLog.class);

    /**
     * log4j-over-slf4j:     log4j  -->  slf4j
     *    slf4j-log4j12:     slf4j  -->  log4j
     */
    private static final org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger(TestLog.class);

    /**
     * jul-to-slf4j:  jdk-logging -->  slf4j
     *  slf4j-jdk14:  slf4j       -->  jdk-logging
     */
    private static final java.util.logging.Logger jul = java.util.logging.Logger.getLogger(TestLog.class.getName());

    public static void main(String[] args) {
        slf4j.info("slf4j: this is logback");
        jcl.info("commons-logging: this is jcl");
        log4j.info("log4j: this is log4j");
        jul.info("jdk-logging: this is jul");

        throw new RuntimeException("2333");
    }
}
